package maurice.game;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.util.ArrayList;

import javax.swing.JPanel;

public class HighScorePanel extends JPanel{
	
	private Font font;
	private ArrayList<String> letters;
	private int index;
	private String name;
	
	public HighScorePanel(){
		font = new Font("Arial", Font.BOLD, 80);
		letters = new ArrayList<String>();
		index = 0;
		
		for (char c = 'A'; c <= 'Z'; c++){
			letters.add(Character.toString(c));
		}
		letters.add("-");
		letters.add("OK");
		name = "";
	}
	
	public void paint(Graphics g){
		super.paint(g);

		g.setFont(font);
		g.drawString("Entre ton nom : ", (getWidth() - g.getFontMetrics().stringWidth("Entre ton nom : "))/2, g.getFontMetrics().getHeight());
		
		g.setColor(Color.BLUE);
		
		g.fillRect((getWidth() - 150)/2, g.getFontMetrics().getHeight()*2, 150, 150);
		g.setColor(Color.WHITE);
		g.drawString(letters.get(index), (getWidth() - g.getFontMetrics().stringWidth(letters.get(index)))/2, g.getFontMetrics().getHeight()*3);
		g.setColor(Color.BLACK);
		g.drawString(name, (getWidth() - g.getFontMetrics().stringWidth(name))/2, g.getFontMetrics().getHeight()*5);
		g.drawString("Tu as fait un nouveau record !", (getWidth() - g.getFontMetrics().stringWidth("Tu as fait un nouveau record"))/2, g.getFontMetrics().getHeight()*7);
	}
	
	public void down(){
		index++;
		index %= 28;
		repaint();
	}
	
	public void up(){
		index--;
		if (index < 0)
			index = 27;
		repaint();
	}
	
	public String getCurrentLetter(){
		return letters.get(index);
	}
	
	public void setName(String name){
		this.name = name;
		repaint();
	}
	
}
